library(dplyr)
library(tidyr)
library(foreign)

# 2012 ANES has too many variables to be opened in Stata
# This code selects the variables needed for the analysis
# and saves them in a new dataset "anes_timeseries_2012_slim.dta" 

t12<-read.dta("/Users/jrthornton/Dropbox/Coauthored projects (shared folders)/Sophistication and equality/Data/anes_timeseries_2012_Stata12.dta")


t12_alt <- select(t12,
# Equality scale:
	egal_equal, 
	egal_notbigprob, 
	egal_worryless, 
	egal_fewerprobs, 
iwrobspre_levinfo, 
interest_following, 
# Involvement items:
	mobilpo_rally, 
	mobilpo_otherwork, 
	mobilpo_sign, 
	mobilpo_ctbcand, 
	mobilpo_ctbpty, 
	mobilpo_rmob, 
# Gay items
	gayrt_discrev_x,
	gayrt_adopt,
	gayrt_marry,
incgroup_prepost_x, 
pid_self, 
libcpre_self,
dem_age_r_x, 
dem_edu, 
pid_x, 
# race
	dem_racecps_asian,dem_racecps_black,dem_racecps_native,
	dem_racecps_othrace,dem_racecps_pacif,dem_racecps_racedkrf,
	dem_racecps_white,dem_hisp,dem_raceeth_x 
,
gender_respondent_x,
orientn_rgay,
ftcasi_illegal,
ftgr_gay,
knowl_housemaj,
weight_full)

write.dta(t12_alt,"/Users/jrthornton/Dropbox/Coauthored projects (shared folders)/Sophistication and equality/Data/anes_timeseries_2012_slim.dta")